package com.wanli.agent.homepage.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.wanli.agent.R;
import com.wanli.agent.bean.ReturncashListBean;
import com.wanli.agent.utils.NumberFormatUtils;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Author: HWC
 * Description: 提现记录列表
 */
public class IncomeShareListAdapter extends RecyclerView.Adapter<IncomeShareListAdapter.ViewHolder> {


    private List<ReturncashListBean.DataBean.ShareMoneyDetailBean> listsBeans;
    private Context context;

    public IncomeShareListAdapter(List<ReturncashListBean.DataBean.ShareMoneyDetailBean> listsBeans) {
        this.listsBeans = listsBeans;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
        context = viewGroup.getContext();
        View inflate = LayoutInflater.from(context).inflate(R.layout.item_income_share_list, viewGroup, false);
        ViewHolder viewHolder = new ViewHolder(inflate);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        ReturncashListBean.DataBean.ShareMoneyDetailBean dataBean = listsBeans.get(position);
        String shareMoney = NumberFormatUtils.formatTwoDecimal(Double.parseDouble(dataBean.getShare_money()) / 100);
        holder.tvReturnMoney.setText(shareMoney + "元");
    }

    @Override
    public int getItemCount() {
        return listsBeans.size() == 0 ? 0 : listsBeans.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_return_money)
        TextView tvReturnMoney;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
